﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Iesi.Collections.Generic;
using Iesi.Collections;

namespace Wanet.PublicPortal.Common.Domain
{
	public class WebPage: BasePersistentItem
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="WebPage"/> class.
		/// </summary>
		public WebPage()
		{
			Modules = new HashedSet<WebModule>();
			Layout = new WebLayout();
		}

		/// <summary>
		/// Gets or sets the name.
		/// </summary>
		/// <value>The name.</value>
		public virtual string Name
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the list of modules that this page contains.
		/// </summary>
		/// <value>The modules.</value>
		public virtual ISet<WebModule> Modules
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the layout.
		/// </summary>
		/// <value>The layout.</value>
		public virtual WebLayout Layout
		{
			get;
			set;
		}

		/// <summary>
		/// Gets the modules for section.
		/// </summary>
		/// <param name="section">The section.</param>
		/// <returns></returns>
		public virtual IList<WebModule> GetModulesForSection(string section)
		{
			if (Modules == null)
			{
				return null;
			}

			return this.Modules.ToList<WebModule>().GetModulesInSection(section);
		}
	}
}
